<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\RetryFailedConvertJob::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
//        $schedule->command('retry-failed-convert-job')->everyMinute();

        $schedule->command('sync-attachments')
            ->withoutOverlapping(60)
            ->everyMinute()
            ->appendOutputTo(storage_path('logs/cmd-sync-attachments'));

        $schedule->command('convert-attachments-for-preview')
            ->withoutOverlapping(60)
            ->everyMinute()
            ->appendOutputTo(storage_path('logs/cmd-convert-attachments-for-preview'));

        $schedule->command('create-sms-tasks')
            ->withoutOverlapping(60)
            ->everyTenMinutes()
            ->appendOutputTo(storage_path('logs/cmd-create-sms-tasks.log'));

        $schedule->command('execute-sms-tasks')
            ->withoutOverlapping(60)
            ->everyFiveMinutes()
            ->appendOutputTo(storage_path('logs/cmd-execute-sms-tasks.log'));
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
